import heapq

n, m = map(int, input().split())
pivot = 2 ** 31
smaller = []  # 大根堆，存储负数
larger = []  # 大根堆，存储负数

for _ in range(n):
    num = int(input())
    if num < pivot:
        heapq.heappush(smaller, -num)
    else:
        heapq.heappush(larger, -num)

for _ in range(m):
    current_small = -smaller[0] if smaller else -1
    current_large = -larger[0] if larger else -1

    if current_small >= current_large and smaller:
        # 处理smaller中的最大元素
        val = -heapq.heappop(smaller)
    else:
        # 处理larger中的最大元素
        val = -heapq.heappop(larger)
    # 乘以2
    new_val = val * 2
    if new_val < pivot:
        heapq.heappush(smaller, -new_val)
    else:
        heapq.heappush(larger, -new_val)

ans = sum(-x for x in smaller) + sum(-x for x in larger)
print(ans)
